/**
 * 
 */
package org.tiger.springboot.redis.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.tiger.common.domain.ResponseBean;
import org.tiger.springboot.redis.service.IRedisTemplateService;

/**
 * @author liuwenlai
 *
 */
@RestController
@RequestMapping("redisTemplateOps")
public class RedisTemplateOpsController {

	@Autowired
	private IRedisTemplateService redisTemplateService;

	@RequestMapping("/getObjByKey")
	public ResponseBean<Object> getObjByKey(String key) {
		ResponseBean<Object> bean = redisTemplateService.getObjByKey(key);

		return bean;
	}

	@RequestMapping("/hasKey")
	public ResponseBean<Object> hasKey(String key) {
		ResponseBean<Object> bean = new ResponseBean<Object>();
		bean.setResult(redisTemplateService.hasKey(key));

		return bean;
	}

	@RequestMapping("/deleteKey")
	public ResponseBean<Object> deleteKey(String key) {
		ResponseBean<Object> bean = new ResponseBean<Object>();
		bean.setResult(redisTemplateService.deleteKey(key));

		return bean;
	}

	@RequestMapping("/setObj")
	public ResponseBean<Object> setObj(String key, String value) {
		ResponseBean<Object> bean = new ResponseBean<Object>();
		redisTemplateService.setObj(key, value);
		// bean.setMessages("test");
		return bean;
	}

}
